import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:shop/route/my_route.dart';
import 'package:shop/shop/life/Index.dart';
import 'package:shop/shop/life/Login.dart';
import 'package:shop/shop/life/TuiHuoPage.dart';
import 'package:shop/shop/life/TuiKuanPage.dart';
class RefundType extends StatefulWidget {
  final String odid;//订单详情id
  final String orid;//订单id
  final String gid;//商品id
  final String orStatus;//订单状态
  RefundType({Key key, this.odid,this.title, this.orid, this.gid, this.orStatus}) : super(key: key);

  final String title;

  @override
  _RefundType createState() => _RefundType(odid,orid,gid,orStatus);
}

class _RefundType extends State<RefundType> {
  final String odid;//订单详情id
  final String orid;//订单id
  final String gid;//商品id
  final String orStatus;//订单状态
  _RefundType(this.odid, this.orid, this.gid, this.orStatus);

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 464, height: 820);
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text("选择售后类型"),
      ),
      body:Column(
        children: [
          orStatus=='1' //用三元运算符展示退款或者退货，退款不退货
              ?
          GestureDetector(
            child: Container(
            height: ScreenUtil().setHeight(100),
            margin: EdgeInsets.all(10),
            padding: EdgeInsets.all(10),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10)) ,
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Icon(Icons.account_balance_wallet_outlined,color: Colors.orange,),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(child: Text("我要退款"),margin: EdgeInsets.only(bottom: 10),),
                    Row(children: [ Text("没收到货，或者是商家还没有发货",style: TextStyle(color: Colors.black38))]),
                  ],
                ),
                Icon(Icons.arrow_forward_ios),
              ],
            ),
          ),
            onTap: ()  async {
              var value = await MyRoute.push(TuiKuanPage(odid: odid,orid: orid,gid: gid,));
              if(value==1){
                MyRoute.pop(1);
              }
            },
          ) :
              Column(children: [
                GestureDetector(
                  child:Container(
                    height: ScreenUtil().setHeight(100),
                    margin: EdgeInsets.all(10),
                    padding: EdgeInsets.all(10),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)) ,
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Icon(Icons.thumb_down_alt_outlined,color: Colors.orange,),
                        Container(
                          padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Container(child: Text("我要退货"),margin: EdgeInsets.only(bottom: 10)),
                              Text("已收到货，要把商品退回给商家",style: TextStyle(color: Colors.black38),)
                            ],
                          ),
                        ),
                        Icon(Icons.arrow_forward_ios),
                      ],
                    ),
                  ),
                  onTap: () async {
                    print("odid="+odid+";orid="+orid+";gid="+gid);
                    var bool = await MyRoute.push(TuiHuoPage(odid: odid,orid: orid,gid: gid,));
                    if(bool==1){
                      MyRoute.pop(1);
                    }
                  },
                ),GestureDetector(
                  child:Container(
                    height: ScreenUtil().setHeight(100),
                    margin: EdgeInsets.all(10),
                    padding: EdgeInsets.all(10),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)) ,
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Icon(Icons.loop,color: Colors.orange,),
                        Container(
                          padding: EdgeInsets.fromLTRB(0, 10, 30, 0),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Container(child: Text("我要换货"),margin: EdgeInsets.only(bottom: 10)),
                              Text("货品不达标，要求更换货品",style: TextStyle(color: Colors.black38),)
                            ],
                          ),
                        ),
                        Icon(Icons.arrow_forward_ios),
                      ],
                    ),
                  ),
                  onTap: () async {
                    print("odid="+odid+";orid="+orid+";gid="+gid);
                    var bool = await MyRoute.push(TuiHuoPage(odid: odid,orid: orid,gid: gid,));
                    if(bool==1){
                      MyRoute.pop(1);
                    }
                  },
                )
              ],)
        ],
      )
    );
  }
}